<?php
class ml_biz_feed{

    private $_data=array();//被处理的数据
    private $_nicks=array();//nick集合
    private $_uids=array();//uid集合
    private $_rids=array();//资源id集合
    private $_quote=array();//被引用的数据
    private $_nickname;//被查看人的昵称

    public function get_html($data,$nickname){

        $this->_data=$data;
        $this->_nickname=$nickname;
        $this->fen();
        $this->getUids();
        $this->getNick();
        $this->he();
        //return  ml_tool_parse2output::parseFeed($this->_data);//模版赋值
        return $this->_data;
    }


    private function getNick(){

        $oAccount = new ml_model_dbUserAccount();
        $rs = $oAccount->getNicksByUids($this->_uids);
        $this->_nicks = $oAccount->get_data();

    }
    /**
     * @fileoverview    这块加个for把引用到的内容的uids得到，然后得到nicks然后赋给引用数组
     *
     */
    private function getUids(){

        foreach ($this->_quote as $contentValue) {
            $this->_uids[]=$contentValue['uid'];
        }
    }
    /**
     * @fileoverview    拆feed数据，获取扩展数据
     *
     */
    private function fen(){

        foreach ($this->_data as $fen) {

            switch ($fen['type']) {
                case ML_FEED_TYPE_ATTITUDE:
                    $this->_rids[]=$fen['feed_info']['rid'];
                    break;
                case ML_FEED_TYPE_REPOST_SHORT:
                    $this->_rids[]=$fen['feed_info']['rid'];
                    break;
                case ML_FEED_TYPE_REPOST_PIC:
                    $this->_rids[]=$fen['feed_info']['rid'];
                    break;
            }
        }

        $modelContent=new ml_model_dbContent();
        $this->_quote=$modelContent->get_content_by_rids($this->_rids);
    }
    /**
     * @fileoverview    合并feed数据,加上昵称，content
     *
     */
    private function he(){

        foreach ($this->_data as &$he) {
            if ($he['type']==ML_FEED_TYPE_ATTITUDE||$he['type']==ML_FEED_TYPE_REPOST_SHORT){//后期加上各种转发
                $he['quote']=$this->_quote[$he['feed_info']['rid']];
                $he['quote']['nick']=$this->_nicks[$he['quote']['uid']];

            }
            $he['nick']=$this->_nickname;
        }

    }
}
?>